package com.example.jiaopin.Mapper;
import com.example.jiaopin.model.Course;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CourseMapper {
    @Select("SELECT * FROM courses WHERE courseID = #{courseID}")
    Course getCourseById(Integer courseID);

    @Insert("INSERT INTO courses(courseName, description, teacherID) VALUES(#{courseName}, #{description}, #{teacherID})")
    @Options(useGeneratedKeys = true, keyProperty = "courseID")
    void insertCourse(Course course);

    @Update("UPDATE courses SET courseName = #{courseName}, description = #{description}, teacherID = #{teacherID} WHERE courseID = #{courseID}")
    void updateCourse(Course course);

    @Delete("DELETE FROM courses WHERE courseID = #{courseID}")
    void deleteCourse(Integer courseID);
}